package org.cuatrovientos.ListaCompraCasosUso;

import java.util.Enumeration;
import java.util.Hashtable;


/**
 * this class represent a list of products
 * @author david_berrade
 *
 */


public class ListProducts {

	
	private  Hashtable<String,Products> allproducts;

	
	/**
	 * constructor for listproducts.
	 */
	 public ListProducts () {
		 
		 allproducts= new Hashtable<String,Products>();
	 }
	 
	/**
	 * Insert new product in the list
	 * @param c
	 */
	public void InsertProducts(Products c){
		
		if( allproducts.containsKey(c.getName())){
			
			System.out.println(" This product already exist in your list");
			
		}else{
			
			allproducts.put(c.getName(), c);	
			
			}
		
	
		/**
		 * Delete product from the list
		 */
	}
	
	public void deleteProducts(String productName){
		
		allproducts.remove(productName);
		
	}
	
	/**
	 * Shows all the hastable
	 * @return
	 */
	public String show(){
		
		String result="";
		Enumeration lista=allproducts.keys();
		String products="";
		
		while (lista.hasMoreElements()){
			
			products=lista.nextElement().toString();
			result+=allproducts.get(products).toString();
			result+="\n---------------------------\n";
		}
		return result;
		
			
			
		}

	
		
		
	
	
	
	
				
		
	}
	
	
	
	

